/*
    XTU OJ: 1479
    by: fifth_light
*/

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

#define MOD 1000000007

int64_t array[1000010];

void prepare() {
    int64_t result = 1;
    for (int i = 0; i < 1000010; i++) {
        array[i] = result;
        result *= 2;
        result %= MOD;
    }
}

int64_t longPow(int count) {
    return array[count];
}

int main() {
    prepare();
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        int n;
        scanf("%d", &n);int64_t result = (((3 * longPow(n - 2)) % MOD) * (n - 1)) % MOD;
        printf("%" PRId64 "\n", result);
    }
    return 0;
}
